home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 02 / msctest.ada < prev    next >
Text File  |  1991-02-10  |  3KB  |  89 lines

  1. -- An ADA program to test the use of the pragma interface for
  2. -- interfacing with Microsoft C programs
  3.  
  4. with Text_IO;   use Text_IO;
  5.  
  6.     package FIO is new Text_IO.Float_IO(Float);
  7.     package IIO is new Text_IO.Float_IO(Float);
  8.  
  9. procedure MSCTEST is       -- MSC = Microsoft C
  10.  
  11.     i, j: integer;         -- compatible with Microsoft_C
  12.     a, b: float;           -- Meridian is 64 bits; be careful
  13.  
  14. procedure msc_start;   -- procedure specification
  15.     pragma INTERFACE(microsoft_C, msc_start);
  16.                            -- This pragma takes the place of the
  17.                            -- body for msc_start. No other code is
  18.                            -- permitted for msc_start once it is
  19.                            -- implemented via a pragma interface
  20.  
  21. procedure msc_end;
  22.     pragma INTERFACE(microsoft_C, msc_end);
  23.  
  24. function cinttst1(x: integer) return integer;
  25.     pragma INTERFACE(microsoft_C, cinttst1);
  26.  
  27.     procedure cinttst2(x, y: integer; z: out integer);
  28.         pragma INTERFACE(microsoft_C, cinttst2);
  29.  
  30.     procedure cflttst(x: in out float; y: in out float);
  31.         pragma INTERFACE(microsoft_C, cflttst);
  32.  
  33.     begin -- MSCTEST
  34.  
  35.        Text_IO.Put_Line("Beginning of AdaVantage/Microsoft-C ");
  36.        Text_IO.Put_Line("Interface Example.");
  37.        Text_IO.NEW_LINE;
  38.  
  39.        TEXT_IO.Put_Line("Calling msc_start.");
  40.        MSC_START;
  41.  
  42.        TEXT_IO.Put_Line("Calling cinttst1 ...");
  43.  
  44.        I := cinttst1(4);
  45.  
  46.        TEXT_IO.New_Line;
  47.        TEXT_IO.Put_Line("... result returned from cinttst1:");
  48.        TEXT_IO.Put("  i (16) = ");
  49.        Iio.put(I);
  50.        TEXT_IO.New_Line(2);
  51.  
  52.        TEXT_IO.Put_Line("Calling cinttst2 ...");
  53.        TEXT_IO.New_Line;
  54.  
  55.        I := 5;
  56.        cinttst2(I, 11, J);
  57.  
  58.        TEXT_IO.New_Line;
  59.        TEXT_IO.Put_Line("... result returned from cinttst2:");
  60.        TEXT_IO.Put("  J (55) = ");
  61.        Iio.Put(j);
  62.        TEXT_IO.New_Line(2);
  63.  
  64.        TEXT_IO.Put_Line("Calling cflttst ...");
  65.        TEXT_IO.New_Line;
  66.  
  67.        A := 1.23456;
  68.        B := 9.87654;
  69.  
  70.        cflttst(A,B);
  71.  
  72.        Text_IO.New_Line;
  73.        Text_IO.Put_Line("... results returned from cflttst:");
  74.        Text_IO.Put("  a (8.76543) = ");
  75.        FIO.Put(A, aft => 5, exp => 0);
  76.        Text_IO.New_Line;
  77.        Text_IO.Put("  b (2.34567) = ");
  78.        FIO.Put(b, aft => 5, exp => 0);
  79.        Text_IO.New_Line(2);
  80.  
  81.        Text_IO.Put_Line("Calling msc_end.");
  82.        MSC_END;
  83.  
  84.        Text_IO.New_Line;
  85.        Text_IO.Put_Line("End of Ada-C Interface Example.");
  86.  
  87.      end MSCTEST;
  88.  
  89.